package com.team7.controller;

import com.team7.service.CourseListService;
import com.team7.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.jsqlparser.statement.select.Limit;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: team7-object
 * @description:
 * @author: 田宏洋
 * @create: 2021-10-19 19:55
 **/

@RestController
@Api("课程列表的接口")
@RequestMapping("/core/courseList")
public class CourseListController {
    @Resource
    private CourseListService courseListService;
    @PostMapping("findCourseList/{page}/{limit}")
    public CommonResult findCourseList(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @RequestBody CourseVo courseVo,@RequestParam(required = false) String id){
        CommonResult courseListByPage = courseListService.findCourseListByPage(page, limit, courseVo, id);
        return courseListByPage;
    }
    @PostMapping("/updateCourse")
    @ApiOperation("修改课程信息")
    public CommonResult updateCourse(@RequestBody UpdateCoursesVo updateCoursesVo){
        return courseListService.updateCourse(updateCoursesVo);
    }
    @PostMapping("/changeStatus")
    @ApiOperation("修改课程上下架状态")
    public CommonResult changeStatus(@RequestBody CourseVo courseVo){
        return courseListService.changeStatus(courseVo);
    }
    @PostMapping("/updateCourseSubject")
    @ApiOperation("修改课程信息及课程分类信息")
    public CommonResult updateCourseSubject(@RequestBody CourseUpVo courseUpVo){
        return courseListService.updateCourseSubject(courseUpVo);
    }
    @GetMapping("/updateAdd")
    @ApiOperation("专区添加的方法")
    public Integer updateAdd(@RequestParam(value = "id",required = false) String id){
        return courseListService.updateIsAdd(id);
    }
    @GetMapping("/getCoursByTeacherPhone/{page}/{limit}/{mobile}/{checkStatus}")
    @ApiOperation("通过讲师手机号，获取讲师的课程信息")
    public CommonResult getCoursByTeacherPhone(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @PathVariable("mobile") String mobile, @PathVariable(value = "checkStatus",required = false)String checkStatus){
        return courseListService.getCoursByTeacherPhone(page,limit,mobile,checkStatus);
    }
    @PostMapping("/findCourseByTeacherId/{page}/{limit}")
    @ApiOperation("通过讲师id,或者课程名称，获取讲师的课程信息")
    public CommonResult findCourseByTeacherId(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @RequestBody TeacherCourseVo teacherCourseVo){
        return courseListService.findCourseByTeacherId(page,limit,teacherCourseVo);
    }
    @GetMapping("/findTeacherByTeacherId/{teacherId}")
    @ApiOperation("通过讲师id，获取讲师的信息")
    public CommonResult findTeacherByTeacherId(@PathVariable(value ="teacherId",required = false ) String teacherId){
        return courseListService.findTeacherByTeacherId(teacherId);
    }

}
